fix: add LAN disable and SD stream interface setup to StartSdCardLoggingAsync#153
fix: add LAN disable and SD stream interface setup to StartSdCardLoggingAsync#153
Conversation
…ingAsync SD card and LAN share the SPI bus on the hardware. StartSdCardLoggingAsync was missing the DisableNetworkLan and SetStreamInterface(SdCard) commands that the desktop app was sending via its PrepareSdInterface() workaround. This caused SD card logging to silently produce no files when called from Core alone (e.g. via the example CLI app). StopSdCardLoggingAsync now also restores the stream interface to USB for USB connections so subsequent non-SD operations work correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: a0fb8798807b
Review Summary by QodoFix SD card logging by disabling LAN and configuring stream interface
WalkthroughsDescription• Disable LAN and set stream interface to SD card before logging • Restore stream interface to USB after SD card logging stops • Update tests to verify new 6-command sequence instead of 4 Diagramflowchart LR
A["StartSdCardLoggingAsync"] --> B["DisableNetworkLan"]
B --> C["EnableStorageSd"]
C --> D["SetStreamInterface SdCard"]
D --> E["SetSdLoggingFileName"]
E --> F["SetStreamFormat"]
F --> G["StartStreamData"]
H["StopSdCardLoggingAsync"] --> I["StopStreaming"]
I --> J["DisableStorageSd"]
J --> K["SetStreamInterface USB"]
File Changes1. src/Daqifi.Core/Device/DaqifiStreamingDevice.cs
|
Code Review by Qodo
1.
|
| StopStreaming(); | ||
| Send(ScpiMessageProducer.DisableStorageSd); | ||
|
|
||
| // Restore stream interface to USB so subsequent non-SD operations work. | ||
| if (IsUsbConnection) | ||
| { | ||
| Send(ScpiMessageProducer.SetStreamInterface(StreamInterface.Usb)); | ||
| } | ||
|
|
There was a problem hiding this comment.
2. Lan not restored on stop 🐞 Bug ⛯ Reliability
StopSdCardLoggingAsync disables SD storage but never re-enables LAN after StartSdCardLoggingAsync disabled it, leaving the device in a LAN-disabled state after logging. This can break later network operations unless callers know to manually call PrepareLanInterface.
Agent Prompt
### Issue description
`StopSdCardLoggingAsync` does not restore the LAN interface after `StartSdCardLoggingAsync` disables it, leaving the device in a LAN-disabled state.
### Issue Context
The class already defines `PrepareLanInterface()` as the standard way to restore LAN (it disables SD storage and enables LAN). Other SD operations restore LAN in `finally` blocks.
### Fix Focus Areas
- src/Daqifi.Core/Device/DaqifiStreamingDevice.cs[439-460]
- src/Daqifi.Core/Device/DaqifiStreamingDevice.cs[272-285]
### Suggested fix
- In `StopSdCardLoggingAsync`, after `Send(DisableStorageSd)`, restore LAN using one of:
- Call `PrepareLanInterface()` (may resend DisableStorageSd but is idempotent), or
- Send `ScpiMessageProducer.EnableNetworkLan` explicitly.
- Consider adding a short settle delay (reuse `SD_INTERFACE_SETTLE_DELAY_MS`) if subsequent commands are likely to follow immediately.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
SD card logging requires USB because SD and LAN share the SPI bus. Add an early guard that throws InvalidOperationException for non-USB connections, matching the existing pattern in DownloadSdCardFileAsync. Also fixes StopSdCardLoggingAsync test to expect the new SetStreamInterface(Usb) restore command, and updates the download non-USB test to use a dedicated TestableNonUsbStreamingDevice. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: a0fb8798807b
Summary
StartSdCardLoggingAsyncnow sendsDisableNetworkLanandSetStreamInterface(SdCard)before enabling SD storage and starting streaming. SD card and LAN share the SPI bus on the hardware — without disabling LAN first, SD card logging silently produces no files.StopSdCardLoggingAsyncnow restores the stream interface to USB (for USB connections) so subsequent non-SD operations work correctly.Context
The desktop app had been working around this via its
PrepareSdInterface()method, which sent these commands before calling Core. When using Core directly (e.g. via the CLI example app), SD card logging would appear to start/stop successfully but no files were written to the card.Test plan
--sd-log-start --sd-log-format csvvia example CLI creates a file on the SD card--sd-log-start --sd-log-format protobufvia example CLI creates a file on the SD card--sd-listshows the new files after logging🤖 Generated with Claude Code